//! \file CFile.cpp
// -----------------------------------------------------------------------------
//! This program is free software; you can redistribute it and/or
//! modify it under the terms of the GNU General Public License
//! as published by the Free Software Foundation; either version 2
//! of the License, or (at your option) any later version.
//!
//! This program is distributed in the hope that it will be useful,
//! but WITHOUT ANY WARRANTY; without even the implied warranty of
//! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//! GNU General Public License for more details.
//!
//! You should have received a copy of the GNU General Public License
//! along with this program; if not, write to the Free Software Foundation,
//! Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
// -----------------------------------------------------------------------------

// Project Includes
#include "CFile.h"

// Standard Includes
#include <stdio.h>
#include <fstream>


namespace code_sheriff
{


// =====[ Public Methods ]======================================================


// =============================================================================
// CFile::CFile
// -----------------------------------------------------------------------------
CFile::CFile(void)
{
  // Initially clear the contents.
  clear();
}


// =============================================================================
// CFile::~CFile
// -----------------------------------------------------------------------------
CFile::~CFile()
{
  // TODO Auto-generated destructor stub
}


// =============================================================================
// CFile::load
// -----------------------------------------------------------------------------
TERROR CFile::load(std::string FileName)
{
  std::ifstream ifs(FileName.c_str());  // Input stream for reading the file contents.
  std::string Line;                     // A single line read from the file.

  // Start with cleared parameters.
  clear();

  // Update the file name with the requested file name.
  m_FileName = FileName;

  // Read each line in from the requested file.
  while (getline(ifs, Line) )
    { m_Lines.push_back(Line); }

  // Return success.
  return (ERROR_NONE);
}


// =====[ Private Methods ]=====================================================


// =============================================================================
// CFile::clear
// -----------------------------------------------------------------------------
void CFile::clear(void)
{
  m_FileName.clear(); // Clear any existing file name.
  m_Lines.clear();    // Clear any existing lines.
}


} // namespace code_sheriff
